//
//  ZDStatusBottomView.m
//  OCSinaWeiBo
//
//  Created by Apple on 15/11/2.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZDStatusBottomView.h"
#import <Masonry/Masonry.h>

@interface ZDStatusBottomView ()

@property (nonatomic, strong) UIButton *forwardButton;     //转发

@property (nonatomic, strong) UIButton *commentButton;     //评论

@property (nonatomic, strong) UIButton *likeButton;        //赞

@property (nonatomic, strong) UIImageView *leftSeparatView;     //左边分割线

@property (nonatomic, strong) UIImageView *rightSeparatView;    //右边分割线

@end

@implementation ZDStatusBottomView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self prepareUI];
    }
    return self;
}


//添加子控件
- (void)prepareUI
{
    self.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
    
    //添加子控件
    [self addSubview:self.forwardButton];
    [self addSubview:self.commentButton];
    [self addSubview:self.likeButton];
    [self addSubview:self.leftSeparatView];
    [self addSubview:self.rightSeparatView];
    
    //添加约束
    [_forwardButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.bottom.mas_equalTo(self);
    }];
    
    [_commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(self);
        make.width.mas_equalTo(_forwardButton);  //mas_equalTo() 默认是与括号内控件相同的属性建立约束，也可以自己指定，比如.mas_width
        make.left.mas_equalTo(_forwardButton.mas_right);
    }];
    
    [_likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.right.mas_equalTo(self);
        make.left.mas_equalTo(_commentButton.mas_right);
        make.width.mas_equalTo(_commentButton);
    }];
    
    [_leftSeparatView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(_forwardButton.mas_right);
        make.centerY.mas_equalTo(self);
    }];
    
    [_rightSeparatView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(_commentButton.mas_right);
        make.centerY.mas_equalTo(self);
    }];
}



#pragma mark 懒加载
- (UIButton *)forwardButton
{
    if (!_forwardButton)
    {
        _forwardButton = [[UIButton alloc] init];
        
        [_forwardButton setImage:[UIImage imageNamed:@"timeline_icon_retweet"] forState:UIControlStateNormal];
    }
    
    return _forwardButton;
}

- (UIButton *)commentButton
{
    if (!_commentButton)
    {
        _commentButton = [[UIButton alloc] init];
        
        [_commentButton setImage:[UIImage imageNamed:@"timeline_icon_comment"] forState:UIControlStateNormal];
    }
    
    return _commentButton;
}

- (UIButton *)likeButton
{
    if (!_likeButton)
    {
        _likeButton = [[UIButton alloc] init];
        
        [_likeButton setImage:[UIImage imageNamed:@"timeline_icon_unlike"] forState:UIControlStateNormal];
    }
    
    return _likeButton;
}

- (UIImageView *)leftSeparatView
{
    if (!_leftSeparatView)
    {
        _leftSeparatView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line_highlighted"]];
    }
    
    return _leftSeparatView;
}

- (UIImageView *)rightSeparatView
{
    if (!_rightSeparatView)
    {
        _rightSeparatView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line_highlighted"]];
    }
    
    return _rightSeparatView;
}

@end
